package com.ap.core.common.tuple;

/**
 * Factory for creating tuples. By using static imports the factory can be used as
 * 
 * <code>v("Foo", true, 1) create an instance of ThreesTuple<String, Boolean, Integer></code>
 *
 */
public class TupleFactory {
    
    /**
     * private constructor to avoid instantiation
     */
    private TupleFactory(){
        //do-nothing
    }

    /**
     * Creates a tuple two elements.
     * 
     * @param <F> Type of the first element of the tuple.
     * @param <S> Type of the second element of the tuple.
     * @param first First element of the tuple.
     * @param second Second element of the tuple.
     * @return An instance of a tuple of two.
     */
    public static <F, S> TwosTuple<F, S> v(F first, S second) {
        TwosTuple<F, S> tuple = new TwosTuple<F, S>();
        tuple.first = first;
        tuple.second = second;
        return tuple;
    }
    
    /**
     * Creates a tuple three elements.
     * 
     * @param <F> Type of the first element of the tuple.
     * @param <S> Type of the second element of the tuple.
     * @param <T> Type of the third element of the tuple.
     * @param first First element of the tuple.
     * @param second Second element of the tuple.
     * @param third Third element of the tuple.
     * @return An instance of a tuple of two.
     */
    public static <F, S, T> ThreeTuple<F, S, T> v(F first, S second, T third) {
        ThreeTuple<F, S, T> tuple = new ThreeTuple<F, S, T>();
        tuple.first = first;
        tuple.second = second;
        tuple.third = third;
        return tuple;
    }

}
